#include "stdafx.h"

void Application::check_mouse_hover(int x, int y)
{
    camera->getCameraToViewportRay(Real(x),Real(y),&ray);
    rsq->execute();
    //    typedef vector<RaySceneQueryResultEntry>::type RaySceneQueryResult;
    for(RaySceneQueryResult::iterator
        a = rsq->getLastResults().begin(); a != rsq->getLastResults().end(); ++a)
    {
        static_cast<Entity*>(a->movable)->setMaterialName("hover/hover");
    }
}

void Application :: init_other()
{
    rsq = new DefaultRaySceneQuery(scmgr);
}

bool Application :: mouseMoved		(const OIS::MouseEvent &e)
{
    cam_node ->   yaw(Radian(- e.state.X.rel * rotating_speed), Ogre::Node::TS_WORLD);
    cam_node -> pitch(Radian(- e.state.Y.rel * rotating_speed));
    ray.setOrigin(cam_node->getPosition());
    ray.setDirection(cam_node->getOrientation() * Vector3(1,1,1));
    check_mouse_hover(e.state.X.abs, e.state.Y.abs);
    return true;
}